"""Utility functions for BigServer."""
import logging
from typing import Any, Dict


def setup_logging(level: str = "INFO"):
    """Set up logging for the application."""
    logging.basicConfig(
        level=getattr(logging, level.upper()),
        format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
    )


def format_multimodal_content(content: Any) -> str:
    """Format multimodal content for processing."""
    if isinstance(content, str):
        return content
    elif isinstance(content, list):
        # Handle multimodal content (text and images)
        text_parts = []
        for item in content:
            if isinstance(item, dict):
                if item.get("type") == "text":
                    text_parts.append(item.get("text", ""))
                elif item.get("type") == "image_url":
                    text_parts.append("[IMAGE]")
            else:
                text_parts.append(str(item))
        return " ".join(text_parts)
    else:
        return str(content)